//
//  Carte.m
//  Truffle
//
//  Affichage MAP comme PLAN
//
//  Created by Fabrice Troilo on 08/02/10.
//  Copyright 2010 DQS. All rights reserved.
//

#import "Carte.h"

@implementation Carte

@synthesize mapView, addAnnotation, longitude, latitude, pseudo, coordinate;

- (void)dealloc {
	[pseudo release];
	[mapView release];
	[addAnnotation release];
    [super dealloc];
}

/*
 * Affichage de la carte au chargement
 */
- (void)viewDidLoad {
    [super viewDidLoad];
	//Affiche la position de l'utilisateur sur l'écran.
	mapView.showsUserLocation = YES;
	
	coordinate.latitude = latitude;
	coordinate.longitude = longitude;
	
	
	MKCoordinateRegion region;
	MKCoordinateSpan span;
	span.latitudeDelta=0.01;
	span.longitudeDelta=0.01;
	region.span=span;
	region.center=coordinate;
	if(addAnnotation != nil) {
		[mapView removeAnnotation:addAnnotation];
		[addAnnotation release];
		addAnnotation = nil;
	}
	addAnnotation = [[AddressAnnotation alloc] initWithCoordinate:coordinate];
	[addAnnotation setMTitle:pseudo];
	[addAnnotation setMSubTitle:@"Connecté"];
	[mapView addAnnotation:addAnnotation];
	[mapView setRegion:region animated:FALSE];
	[mapView regionThatFits:region];
	
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
	self.mapView = nil;
}


@end
